import React from 'react'
import { Button, Input, Row, Col, Form } from 'antd'
const FormItem = Form.Item;
/**
 * props示例：
 * {
      name: 'query',
      label: '关键词',
      text: '名称or编号',
      handle:simpleSubmit, //function
      reset:simpleReset, //function
    }
 */
//按关键字搜索的表单
const SimpleForm = (props) => {
  const {name, label, text, handle, reset} = props;
  let form_;

  return <form ref={ node => {
    form_ = node
  } } onSubmit={(e) => {
    e.preventDefault();
    e.stopPropagation();
    handle(form_);
  }}>
    <FormItem
      labelCol={{span: 5}}
      wrapperCol={{span: 19}}
      label={label}
    >
      <Input name={name} placeholder={text}/>
    </FormItem>
    <Row>
      <Col span={24} style={{textAlign: 'right'}}>
        <Button style={{marginRight: 8}} onClick={(e) => {
          form_.reset();
          reset(form_);
        }}>
          重置
        </Button>
        <Button type="primary" htmlType="submit">确定</Button>
      </Col>
    </Row>
  </form>
}

export default SimpleForm
